import React,{useEffect,useContext} from "react";
import { Text,View,StyleSheet } from "react-native";
import { Button } from '@ant-design/react-native';
import { navigate,request,confirm,useLoading,dp } from "../../utils/common";
import { useSelector } from 'react-redux';
import {
  getter
} from '../../store/reducers/News/index';

const NewsScreen = (props:any)=>{

  const { user_name } = useSelector(getter);

  const [ showLoading,hideLoading ] = useLoading();

  const showModal = ()=>{
    confirm({
      message:"在线测试一下",
      callback(){
        showLoading();
        setTimeout(()=>{
          hideLoading();
        },3000)
      } 
    })
  } 

  const jump = ()=>{
    navigate("Login");
  }

  return (<View>
           <Text onPress={()=>{showModal()}}>新闻首页</Text>
           <Button onPress={jump}>跳转 -- {user_name}</Button>
           <View style={styles.container}></View>
      </View>)
 }


 const styles = StyleSheet.create({
    container:{
      width:dp(375),
      height:dp(20),
      borderWidth:dp(2),
      borderColor:"red"
    }
 })

export default NewsScreen;